<template>
    <!-- 添加或修改角色配置对话框 -->
    <el-dialog :title="title" v-model="open" width="800px" append-to-body @close="close">
        <el-form ref="form" :model="form" :rules="rules" label-width="150px">
            <el-form-item label="客户端ID" prop="clientId">
                <el-input v-model="form.clientId" placeholder="请输入角色名称"/>
            </el-form-item>
            <el-form-item label="授权方式" prop="authorizedGrantTypes">
                <el-select :multiple="true" v-model="form.authorizedGrantTypes">
                    <el-option
                            v-for="dict in grantTypeOptions"
                            :key="dict.dictValue"
                            :label="dict.dictLabel"
                            :value="dict.dictValue"
                    ></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="授权范围">
                <el-select v-model="form.scope">
                    <el-option
                            v-for="dict in scopeOptions"
                            :key="dict.dictValue"
                            :label="dict.dictLabel"
                            :value="dict.dictValue"
                    ></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="授权资源列表">
                <el-input v-model="form.resourceIds" type="textarea" placeholder="请输入内容"></el-input>
            </el-form-item>
            <el-form-item label="授权权限">
                <el-input v-model="form.authorities" type="textarea" placeholder="请输入内容"></el-input>
            </el-form-item>
            <el-form-item label="令牌时效">
                <el-input-number v-model="form.accessTokenValidity" type="textarea" placeholder="请输入内容"></el-input-number>
            </el-form-item>
            <el-form-item label="刷新时效">
                <el-input-number v-model="form.refreshTokenValidity" type="textarea" placeholder="请输入内容"></el-input-number>
            </el-form-item>
            <el-form-item label="回调地址">
                <el-input v-model="form.webServerRedirectUri" type="textarea" placeholder="请输入内容"></el-input>
            </el-form-item>
            <el-form-item label="预留字段">
                <el-input v-model="form.additionalInformation" type="textarea" placeholder="请输入内容"></el-input>
            </el-form-item>
            <el-form-item label="自动放行">
                <el-input v-model="form.autoapprove" type="textarea" placeholder="请输入内容"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
        </div>
    </el-dialog>
</template>

<script>
    //import {addAuth, updateAuth} from "/src/api/system/auth";

    export default {
        name: "update",
        emits: ['dialogStatusChanged'],
        props: {
            open: Boolean,
            title: String,
            form: Object,
            scopeOptions: Array,
            grantTypeOptions: Array,
        },
        data() {
            return {
                // 表单校验
                rules: {
                    clientId: [
                        {required: true, message: "客户端ID不能为空", trigger: "blur"}
                    ],
                    authorizedGrantTypes: [
                        {required: true, message: "授权方式不能为空", trigger: "blur"}
                    ]
                }
            }
        },
        methods: {
            //提交
            submitForm() {
                this.$refs['form'].validate(valid => {

                })
            },
            //取消
            cancel() {
                this.$emit('dialogStatusChanged', false)
            },
            //关闭
            close() {
                this.$emit('dialogStatusChanged', false)
            }
        }
    }
</script>

<style scoped>

</style>
